# coding:utf-8
# Author : hiicy redldw
# Date : 2019/01/24
import numpy as np
from numpy import *
# https://blog.csdn.net/xc_zhou/article/details/81535033
# https://blog.csdn.net/jemila/article/details/69224355
# 欧式距离公式
vector1 = mat([1,2,3])
vector2 = mat([4,5,6])
print(sqrt((vector1 - vector2) * ((vector1 - vector2).T)))


x = np.random.random(10)
y = np.random.random(10)
# solution1
dist1 = np.linalg.norm(x - y)
# solution2
dist2 = np.sqrt(np.sum(np.square(x - y)))
print('x', x)
print('y', y)
print('dist1:', dist1)
print('dist2:', dist2)

# solution3
from scipy.spatial.distance import pdist

X=np.vstack([x,y])
d2=pdist(X)[0]
print('d2:',d2)
